<template>
  <div class="c-item">
    <div class="c-item-header-wrapper">
      <div class="c-item-header">
        <div class="header-left">
          <img class="header-icon" :src="icon" alt="">
          <span class="header-title">{{ title }}</span>
        </div>
        <div class="header-right" v-if="showRight">
          <div class="add-text" @click="clickRight">{{ rightText }}</div>
        </div>
        <slot name="right"></slot>
      </div>
    </div>
    <div class="c-item-body">
      <slot></slot>
    </div>
  </div>
</template>
<script setup>
defineProps({
  title: {
    type: String,
    default: ''
  },
  icon: {
    type: String,
    default: ''
  },
  showRight: {
    type: Boolean,
    default: true
  },
  rightText: {
    type: String,
    default: '添加内容'
  }
})
const emit = defineEmits(['clickRight'])
function clickRight() {
  emit('clickRight')
}
</script>

<style lang="scss">
.dark {
  .c-item {
    .c-item-header {
      border-color: #7B7D80;
    }
    .c-item-body {
      background-color: #1A1D22;
    }
    .header-title,
    .add-text {
      color: #FFFFFF;
    }
  }
  .c-item1 {
    .c-item-header-wrapper {
      background: linear-gradient( 180deg, #385655 0%, #1A1D22 100%);
    }

  }
  .c-item2 {
    .c-item-header-wrapper {
      background: linear-gradient( 180deg, #383B56 0%, #1A1D22 100%);
    }
  }

  .c-item3 {
    height: 387px;
    .c-item-header-wrapper {
       background: linear-gradient( 180deg, #384A56 0%, #1A1D22 100%);
    }
  }
  .c-item4 {
    height: 387px;
    .c-item-header-wrapper {
      background: linear-gradient( 180deg, #384256 0%, #1A1D22 100%);
    }
  }
  .c-item5 {
    height: 387px;
    .c-item-header-wrapper {
      background: linear-gradient( 180deg, #3F3856 0%, #1A1D22 100%);
    }
  }
  .c-item6 {
    height: 387px;
    .c-item-header-wrapper {
      background: linear-gradient( 180deg, #4A4F5B 0%, #24272E 100%);
    }
  }

}
.c-item-header-wrapper {
  padding: 0 17px;
}
.c-item {
  width: 100%;
  height: 230px;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  &.un-line .c-item-header{
    border-bottom: none;
  }
  .c-item-body {
    flex-grow: 1;
    padding:0 17px 20px 17px;
    overflow: auto;
  }
  .c-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    border-bottom: 1px solid;
  }
  .header-title,
  .add-text {
    font-family: PingFangSC, PingFang SC;
    font-weight: 600;
    font-size: 12px;
    line-height: 17px;
  }
  .header-title {
    font-size: 14px;
  }
  .header-icon {
    width: 15px;
    height: 15px;
    margin-right: 10px;
  }
}
</style>
